<template>
  <div class="salarys">
    <el-card>
      <h2>测试上传组件</h2>
      <uploadimg :imgUrl.sync="imgUrl"></uploadimg>
    </el-card>
    <el-card>
      <h3>qrcode 的使用：地址转二维码</h3>
      <img style="width: 100px; height: 100px" :src="imgUrl" alt="" />
      <el-button @click="turnCode">点我将图片地址转为二维码</el-button>
      <h3>在这里面显示二维码</h3>
      <div>
        <canvas ref="myCanvas" />
      </div>
    </el-card>
  </div>
</template>

<script>
import QrCode from 'qrcode'
export default {
  data () {
    return {
      imgUrl:
        'https://img2.baidu.com/it/u=2511950484,2447769399&fm=26&fmt=auto&gp=0.jpg'
    }
  },
  methods: {
    turnCode () {
      QrCode.toCanvas(this.$refs.myCanvas, this.imgUrl, {
        width: 200, // 生成二维码的宽度
        height: 200 // 生成二维码的高度
      })
    }
  }
}
</script>

<style lang="scss">
.salarys {
  padding: 20px;
}
</style>
